//
//  PTStuLSReleaseDetailGradeCell.m
//  PlanTech
//  发布详情-评分区域
//  Created by ruifeng song on 2018/7/12.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "PTStuLSReleaseDetailGradeCell.h"
#import "XHStarRateView.h"

@interface PTStuLSReleaseDetailGradeCell()

@property(nonatomic,strong)UIView * backView;
@property(nonatomic,strong)UILabel * gradeLabel;
@property(nonatomic,strong)UILabel * gradeTitleLabel;
@property(nonatomic,strong)XHStarRateView *starRateView;

@end

@implementation PTStuLSReleaseDetailGradeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        _backView = [[UIView alloc]initWithFrame:CGRectMake(12, 10, ScreenWidth -24, 70)];
        _backView.layer.cornerRadius = 6;
        _backView.layer.masksToBounds = YES;
        _backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_backView];
        
        _gradeLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,(_backView.height - 15)/2 , 100, 15)];
        _gradeLabel.text = @"满意度评价：";
        _gradeLabel.font = PTFONT_15;
        _gradeLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_gradeLabel];
    
        _starRateView = [[XHStarRateView alloc]initWithFrame:CGRectMake( _gradeLabel.right, (self.backView.height-18)/2, 160, 18) numberOfStars:5 selectNumberStars:0 rateStyle:WholeStar isAnination:YES isTouch:NO finish:^(CGFloat currentScore) {
            
        }];
        [_backView addSubview:_starRateView];
        
        _gradeTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(_starRateView.right +3,(self.backView.height - 15)/2 , 80, 15)];
        _gradeTitleLabel.text = @"(很差)";
        _gradeTitleLabel.font = PTFONT_15;
        _gradeTitleLabel.textColor = PTColor_2e2e2e;
        [_backView addSubview:_gradeTitleLabel];
    }
    return self;
}

-(void)updateServiceGradeCell:(NSNumber *)ratingNum
{
    CGFloat starNum = 0;
    if (ratingNum !=nil) {
        
        starNum = [ratingNum floatValue];
    }

    [self.starRateView setCurrentScore:starNum];
    
    if (starNum <=1) {
       self.gradeTitleLabel.text = @"(非常差)";
    }
    else if (starNum>1 && starNum<=2)
    {
        self.gradeTitleLabel.text = @"(差)";
    }
    else if (starNum>2 &&starNum <=3)
    {
        self.gradeTitleLabel.text = @"(一般)";
    }
    else if (starNum>3 && starNum<=4)
    {
        self.gradeTitleLabel.text = @"(好)";
    }
    else if (starNum >4 && starNum <=5)
    {
        self.gradeTitleLabel.text = @"(非常好)";
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
